package nix.demo8.web.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONArray;
import nix.demo8.domain.Province;
import nix.demo8.service.Service;

public class ProvinceServlet extends HttpServlet {

	private Service service = new Service();

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html;charset=utf-8");

		List<Province> provinceList = service.findAllProvince();
		String json = JSONArray.fromObject(provinceList).toString();
		response.getWriter().print(json);
	}

}
